[#include "/includes/_layout.html"/]
<script type="text/javascript">
$(document).ready(function() {
	searchItems();
	$('#conf_pay_dialog').on('hidden.bs.modal', function () {
		$("#sel_app_id").val("");
		 $("#pay_mch_id").val("");
		 $("#pay_secret_key").val("");
		return false;
	});
});
var pageClick = function(pageNo) {
	searchItems(pageNo);
}
var searchItems = function(currPage){
	var params = {};
	//其他查询条件
	if(currPage){
		params.page = currPage;
	}
	params.active = $("#a_status_sel").val();
	$("#mainTable").mask("加载中...");
	var url = obz.ctx + "/setting/listxcx";
	obz.ajaxJson(url, params, function(resp){
		var result = resp.data;
		$(".itemsLotGrid").empty();
		
		if(currPage){
			$("#pager").pager({ pagenumber:currPage, recordcount:result.totalRow, pagesize:result.pageSize, recordtext:'共 {0} 页, {1} 条记录', buttonClickCallback: pageClick });
		}else{
			$("#pager").pager({ recordcount:result.totalRow, pagesize:result.pageSize, recordtext:'共 {0} 页, {1} 条记录', buttonClickCallback: pageClick });	
		}
		
		var dataList = result.list;
		if(dataList.length>0){
			for(var i=0;i<dataList.length;i++){
				var _row = dataList[i];
				if(_row.service_type ==0) {
					_row.s_type="小程序";
				}else {
					_row.s_type="未知类型";
				}
				var trHtml = obz.dataTemplate4obj($("#item_table_tr_tpl").html(), _row);
				$(".itemsLotGrid").append(trHtml);
			}
			//初始化checkbox点击事件
			TBatch.checkCheckbox();
			TBatch.initCheckboxClick();
			TBatch.initOptEvent(TableOpt.init());
		}else{
			$(".itemsLotGrid").append($("#table_noresult_tr_tpl").html());
		}
		
		$("#mainTable").unmask();
	});
}
var TableOpt = {
	configPub : function(param){
		var id = param[1];
		location.href = obz.ctx + "/setting/pack/"+id;
	}, 
	init : function(){
		var optArray = new Array();
		optArray.push(this.configPub);
		return optArray;
	}
} 
</script>
[@layout]
<div class="wrapper wrapper-content">
<div class="row animated fadeInLeft">
	
	[#include "/includes/menus-setting.html" /]
	
	<div class="col-sm-11">
	<div class="row content-tabs">
		<nav class="page-tabs J_menuTabs">
	       <div class="page-tabs-content" style="margin-left: 0px;">
		       <a href="${webctx}/setting/xiaocx" class="J_menuTab active">小程序</a>
	       </div>
	   	</nav>
	</div>
	<div id="tableList" class="content row ibox-content">
		<div class="panel-body">
			<a href="${webctx}/weixin/auth2" class="btn btn-info">绑定小程序
			&nbsp;<i class="fa fa-question-circle" onmouseout="layer.closeAll();" onmouseover="layer.tips('只有认证过的小程序才能绑定。', this, {tips: [1, '#3595CC'],time: 0});"></i>
			</a>
		</div>	
		<div id="prizeToolsbar" class="panel-body">
			<div id="pager" class="jqpager" style="margin-bottom: 1px;"></div>	
		</div>
		<table id="mainTable" class="table table-striped table-bordered bootstrap-datatable datatable" border="0">
		  <thead>
			  <tr>
				<th><input type="checkbox" id="all" title="全选/反选" style="margin-right: 4px; vertical-align: middle;"/></th>
				<th>小程序</th>
				<th>主体名称</th>
				<th>原始Id</th>
				<th><span style="vertical-align: middle;">&nbsp;&nbsp;appId</span></th>
				<th>首次绑定时间</th>
				<th>操作</th>
			  </tr>
		  </thead>   
		  <tbody class="itemsLotGrid">								
		  </tbody>
	  	</table>
	</div>    
</div>
</div>
</div>
<!-- html 模板文件 -->
<script type="text/template" id="item_table_tr_tpl">
		<tr class="package">
			<td><input type="checkbox" class="commchk" id="checkbox_{app_id}" style="margin-right: 4px; vertical-align: middle;"/></td>
			<td><span style="margin-right: 5px; margin-left: 2px; vertical-align: middle;"><img src="{head_img}" width="40" height="40">&nbsp;{nick_name}&nbsp;<font color="blue">({s_type})</font></img></span></td>
			<td>{principal_name}</td>
			<td><span>{user_name}</span></td>
			<td><span style="margin-right: 5px; margin-left: 2px; vertical-align: middle;">{app_id}</span></td>
			<td><span class="fans_status">{created}</span></td>
			<td>&nbsp;<a id="configpub_{id}" href="javascript:void(0)">打包发布</a></td>
		</tr>
</script>
<script type="text/template" id="table_noresult_tr_tpl">
	<tr class="package"><td colspan="7" class="center">没有结果集</td></tr>
</script>
[/@layout]
<script type="text/javascript">
	Template.init("#menu-setting");
	Template.initSecond("#menu-routine");
</script>